package sis.testio.pushback;/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-07-29 11:16
 * @notify
 * @version 1.0
 */

import junit.framework.TestCase;

import java.io.ByteArrayInputStream;
import java.io.PushbackInputStream;

public class PushbackTest extends TestCase {
    public static void main(String args[]) throws Exception {
        String s = "abcdefg";
        ByteArrayInputStream in = new ByteArrayInputStream(s.getBytes());
        PushbackInputStream pbin = new PushbackInputStream(in);
        int n;
        int i=1;
        while ((n = pbin.read()) != -1) {
            if ('b' == n){
                pbin.unread('*');
            }
            System.out.print(i);
            ++i;
            System.out.print((char) n);
        }
    }
}
